package com.xbongbong.paas.service.field;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.help.FormDataAnalysisHelp;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author 吴峰
 * @date 2022/04/01 10:42
 */
@Service("stageAnalysisHandlerImpl")
public class StageAnalysisHandlerImpl extends AbstractFieldAnalysisHandler {

    @Resource
    private FormDataAnalysisHelp formDataAnalysisHelp;

    @Override
    public List<Integer> fieldType() {
        return Arrays.asList(FieldTypeEnum.STAGE_THRUSTER.getType());
    }

    @Override
    public Object getValue(FieldAttrEntity fieldAttrEntity, PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAnalysisPoJo fieldAnalysisPoJo) throws XbbException {
        return formDataAnalysisHelp.getStageValue(fieldAnalysisPoJo.getCorpid(), fieldAttrEntity, data, fieldAnalysisPoJo.getFormId(), fieldAnalysisPoJo.getBusinessType(), fieldAnalysisPoJo.getSaasMark());
    }
}
